package com.ruoyi.paipan.common;

import com.ruoyi.paipan.utils.LunarUtil;

public class XiaoYun {
    private int index;
    private DaYun daYun;
    private int year;
    private int age;
    private Lunar lunar;
    private boolean forward;

    public XiaoYun(DaYun daYun, int index,boolean forward)
    {
        this.daYun = daYun;
        this.lunar = daYun.getLunar();
        this.index = index;
        this.year = daYun.getStartYear() + index;
        this.age = daYun.getStartAge() + index;
        this.forward = forward;
    }

    public int getIndex()
    {
        return this.index;
    }

    public DaYun getDaYun()
    {
        return this.daYun;
    }

    public int getYear()
    {
        return this.year;
    }

    public int getAge()
    {
        return this.age;
    }

    public Lunar getLunar()
    {
        return this.lunar;
    }

    public boolean isForward()
    {
        return this.forward;
    }

    public String getGanZhi()
    {
        int offset = LunarUtil.getJiaZiIndex(this.lunar.getTimeInGanZhi());
        int add = this.index + 1;
        if (this.daYun.getIndex() > 0) {
            add += this.daYun.getStartAge() - 1;
        }
        offset += this.forward ? add : -add;
        int size = LunarUtil.JIA_ZI.size();
        while (offset < 0) {
            offset += size;
        }
        offset %= size;
        return LunarUtil.JIA_ZI.get(offset);
    }

    public String getXun()
    {
        return LunarUtil.getXun(this.getGanZhi());
    }

    public String getXunKong()
    {
        return LunarUtil.getXunKong(this.getGanZhi());
    }

    public static void main(String[] args) {
        System.out.println("XiaoYun");
    }
}
